#!/bin/bash
# 查找并杀死占用CPU最多的进程

HIGH_CPU_PROCESS=$(ps -eo pid,user,%cpu,cmd --sort=-%cpu | head -n 2 | tail -n 1 | awk '{print $1}')
if [ ! -z "$HIGH_CPU_PROCESS" ]; then
    echo "杀死高CPU占用进程：$HIGH_CPU_PROCESS"
    kill -9 $HIGH_CPU_PROCESS
fi